// pages/evaluate/evaluate.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    paddingTop: app.globalData.model.topMargin,
    navHeight: app.globalData.model.topHeight,
    bottomHeight: app.globalData.model.bottomHeight,

    starMap: [
      '非常差',
      '差',
      '一般',
      '很好',
      '非常好',
    ],
    starscores: [
      {
        id: 0,
        title: '商品评分',
        star: 0
      },
      {
        id: 1,
        title: '商家评分',
        star: 0
      }
    ],
    picarr: []
  },
  /**
   * 评分
   */
  chooseStar: function (e) {
    const index = e.currentTarget.dataset.index;
    const star = e.target.dataset.star;
    let starscores = this.data.starscores;
    let starscore = starscores[index];
    starscore.star = star;
    //console.log(e)
    this.setData({
      starscores: starscores
    })
  },
  add1() {
    let that = this;
    let arr = that.data.picarr
    wx.chooseImage({
      count: 3 - that.data.picarr.length,
      sizeType: ['compressed'],
      sourceType: ['album'],
      success: function(res){
        arr.push([...res.tempFilePaths])
        console.log(arr)
        that.setData({
          picarr: arr
        })
      }
    })
  },
  onDelete(e){
    let that = this;
    let arr = that.data.picarr;
    wx.showModal({
      content: '是否删除此照片？',
      success: function(res){
        if(res.confirm){
          arr.splice(e.currentTarget.dataset.index, 1)
          that.setData({picarr: arr})
        }
      }
    })
    
  },
  onSubmit(){
    
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})